package com.nhjf.dao.sms;

import org.apache.commons.lang.StringUtils;
import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.nhjf.common.util.DateUtil;
import com.nhjf.dao.BaseDao;
import com.nhjf.model.sms.SmsSendLog;
import com.nhjf.pojo.qo.sms.SmsSendLogQo;

@Repository
public class SmsSendLogDao extends BaseDao<SmsSendLog, SmsSendLogQo>{

	@Override
	protected Criteria buildCriteria(Criteria criteria, SmsSendLogQo qo) {
		// TODO Auto-generated method stub
		if(qo!=null){
			if(!StringUtils.isEmpty(qo.getPhoneNumber())){
				criteria.add(Restrictions.eq("phoneNumber", qo.getPhoneNumber()));
			}
			if(qo.getType()!=null){
				criteria.add(Restrictions.eq("type", qo.getType()));
			}
			if(qo.getSendTime()!=null){
				criteria.add(Restrictions.ge("sendTime",qo.getSendTime()));
			}
			 criteria.addOrder(Order.desc("sendTime"));
		}
		return criteria;
	}

	@Override
	protected Class<SmsSendLog> getEntityClass() {
		// TODO Auto-generated method stub
		return SmsSendLog.class;
	}

}
